#region

using Gurock.SmartInspect;
using Microsoft.Practices.Unity.InterceptionExtension;

#endregion

namespace SmartInspect.Extensions.Unity
{
    public class SiThreadCallHandler : SiWrappedCallHandler
    {
        private string _threadName;
        public string ThreadName { private get; set; }

        protected override void Enter(IMethodInvocation input, Session ses)
        {
            _threadName = FormatTitle(string.IsNullOrEmpty(ThreadName) ? input.MethodBase.Name : ThreadName);
            ses.SendCustomProcessFlow(_threadName, ProcessFlowType.EnterThread);
        }

        protected override void Leave(IMethodInvocation input, Session ses, IMethodReturn ret)
        {
            ses.SendCustomProcessFlow(_threadName, ProcessFlowType.LeaveThread);
        }
    }
}